editorconfig-core-handle.el: Reduce allocation in parser
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 18 Jun 2024 22:16:10 +0000 (18:16 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 19 Jun 2024 20:18:58 +0000 (16:18 -0400)
commit833b500a0e788a95c189a5b2bfa95494a3a7429e
treef11074d7c78cf391a15f406ab17cea91968499ef
parentee309f77543ac53e407a4b3ca7001bc920099d1b
editorconfig-core-handle.el: Reduce allocation in parser

* lisp/editorconfig-core-handle.el (editorconfig-core-handle--parse-file):
Return a `editorconfig-core-handle`.
(editorconfig-core-handle): Simplify accordingly.
(editorconfig-core-handle--parse-file): Push `sections` and `props`
in reverse order to avoid the usual O(N²) complexity.
Work directly in the buffer instead of extracting "lines" from it, so
as to reduce memory allocation.  Similarly, use careful regexps so we
can extract trimmed strings without an explicit trim operation.
Use `eobp`.
(editorconfig-core-handle--string-trim): Delete function, not used any more.
lisp/editorconfig-core-handle.el